<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IPayAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IConnectionAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/ConnectionFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];

  	class MySqlPayAccessDao implements IPayAccessDao {
  		/**
		 * Constructor of the Pay dao
		 */
	 	public function __construct () {}
		
		/**
		 * Creates pay exhele
		 */
     	public function createPayExhele($pay) {
			$GLOBALS['debug']->log("Inicio Dao exhele");
			$nameExhele = $pay -> getName();
			$amountExhele = $pay -> getAmount();
			$numberExhele = $pay -> getNumber();
			$exheleDate = $pay -> getDate();

			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
			
				$query = "INSERT INTO PAY (name, amount, numberPay, datePay, tipo) VALUES ('$nameExhele', '$amountExhele', '$numberExhele','$exheleDate','exhele')";
		
					
			$sentence = mysql_query($query, $conn);
		
			$GLOBALS['debug']->log("Query Dao exhele"."  ".$query);
			if ($sentence)
			{
				return true;
					$GLOBALS['debug']->log("Fin Dao exhele");
			}
			else
			{
			return false;
			}
	 	}
	 
		 	 /**
		 * Creates pay Installation
		 */
     	public function createPayInstallation($pay) {
			$GLOBALS['debug']->log("Inicio Dao installation");
			$nameInstallation = $pay -> getName();
			$amountInstallation = $pay -> getAmount();
			$numberInstallation = $pay -> getNumber();
			$installationDate = $pay -> getDate();

			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
			
				$query = "INSERT INTO PAY (name, amount, numberPay, datePay, tipo) VALUES ('$nameInstallation', '$amountInstallation', '$numberInstallation','$installationDate','installation')";
		
					
			$sentence = mysql_query($query, $conn);
		
			$GLOBALS['debug']->log("Query Dao installation"."  ".$query);
			if ($sentence)
			{
				return true;
					$GLOBALS['debug']->log("Fin Dao installation");
			}
			else
			{
			return false;
			}
	 	}
	 
		 	 /**
		 * Creates pay publicity
		 */
     	public function createPayPublicity($pay) {
			$GLOBALS['debug']->log("Inicio Dao publicity");
			$namePublicity = $pay -> getName();
			$amountPublicity = $pay -> getAmount();
			$numberPublicity = $pay -> getNumber();
			$publicityDate = $pay -> getDate();

			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
			
				$query = "INSERT INTO PAY (name, amount, numberPay, datePay, tipo) VALUES ('$namePublicity', '$amountPublicity', '$numberPublicity','$publicityDate','publicity')";
		
					
			$sentence = mysql_query($query, $conn);
		
			$GLOBALS['debug']->log("Query Dao publicity"."  ".$query);
			if ($sentence)
			{
				return true;
					$GLOBALS['debug']->log("Fin Dao publicity");
			}
			else
			{
			return false;
			}
	 	}
	 
		 	 
	
		 

		 
  
  }


?>